home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Die Speccy' 97
/
Die Speccy' 97.iso
/
amiga_system
/
the_aminet
/
util
/
cli
/
gengui21.lha
/
Gengui2.1
/
Examples
/
palette.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-06-18
|
3KB
|
100 lines
#include <stdlib.h>
#include <stdio.h>
#include <proto/intuition.h>
#include <intuition/intuition.h>
#include <proto/exec.h>
#include <proto/graphics.h>
#include <proto/layers.h>
#include <libraries/gadtools.h>
#include "palette.h"
#include <graphics/gfxmacros.h>
extern struct IntuitionBase *IntuitionBase;
extern struct GfxBase *GfxBase;
extern struct Library *GadToolsBase;
main()
{
struct IntuiMessage *msg;
struct Window *win;
int run=1;
struct TextFont *font=NULL;
struct Hook hook;
int depth;
hook.h_Entry=(HOOKFUNC)HookFunc;
hook.h_SubEntry=NULL;
hook.h_Data=COLOR(2,0);
win=OpenWindowTags(NULL,
WA_Left,0,WA_Top,20,
WA_Width,300,WA_Height,100,
WA_Title,"Palette",
WA_IDCMP,BUTTONIDCMP|IDCMP_CLOSEWINDOW|SLIDERIDCMP|
IDCMP_NEWSIZE|IDCMP_REFRESHWINDOW|
IDCMP_SIZEVERIFY,
WA_Flags,WFLG_SIZEGADGET|WFLG_DRAGBAR|WFLG_DEPTHGADGET
|WFLG_SIMPLE_REFRESH
|WFLG_CLOSEGADGET|WFLG_ACTIVATE,
WA_MinWidth,300,WA_MinHeight,100,
WA_MaxWidth,-1,WA_MaxHeight,-1,
WA_BackFill,&hook,
TAG_DONE );
if(!win) exit(0);
depth=win->RPort->BitMap->Depth;
GG_SetLowlevelAttrs(&TestPro_GadInfo_PALETTE,GTPA_Depth,depth,TAG_DONE);
if(GG_SmartRenderGui(win,&TestPro,&font)) {CloseWindow(win);if(font) CloseFont(font);exit(0);}
PaletteHook(NULL); /* Initialize palette */
while(run) {
WaitPort(win->UserPort);
while(msg=GG_GetIMsg(win->UserPort)) {
switch(msg->Class) {
case IDCMP_CLOSEWINDOW: run=0;
break;
case IDCMP_NEWSIZE: GG_ResizeGui(&TestPro);
break;
case IDCMP_REFRESHWINDOW:
GG_RefreshGui(&TestPro);
break;
case IDCMP_SIZEVERIFY: GG_BeginResizeGui(&TestPro);
break;
case IDCMP_GADGETUP:
switch(GetGadget(msg)->GadgetID) {
case PLUS: if(depth<win->RPort->BitMap->Depth) {
depth++;
GG_SetLowlevelAttrs(&TestPro_GadInfo_PALETTE,GTPA_Depth,depth,TAG_DONE);
GG_ResizeGui(&TestPro);
}
break;
case MINUS: if(depth>1) {
depth--;
GG_SetLowlevelAttrs(&TestPro_GadInfo_PALETTE,GTPA_Depth,depth,TAG_DONE);
GG_ResizeGui(&TestPro);
}
break;
}
break;
}
GG_ReplyIMsg(msg);
}
}
GG_FreeGui(&TestPro);
CloseWindow(win);
if(font) CloseFont(font);
return(0);
}